import request from "@/utils/request";

//获取商品列表
export function getGoods(params) {
  return request({
    method: "get",
    url: `/goods`,
    params,
  });
}

//删除商品
export function delGood(id) {
  return request({
    method: "delete",
    url: `/goods/${id}`,
  });
}

//查询商品
export function searchGood(params) {
  return request({
    method: "GET",
    url: `/goods/`,
    params,
  });
}

//获得商品分类
export function getcate() {
  return request({
    method: "GET",
    url: `/categories`,
  });
}

//获得商品动态参数
export function getParameter(id) {
  return request({
    method: "GET",
    url: `/categories/${id}/attributes`,
    params: {
      sel: "many",
    },
  });
}

//获得商品静态参数
export function getOnly(id) {
  return request({
    method: "GET",
    url: `/categories/${id}/attributes`,
    params: {
      sel: "only",
    },
  });
}

//添加商品
export function addGood(data) {
  return request({
    method: "post",
    url: `/goods`,
    data: data,
  });
}
